<template>
  <div class="m-waterfall-wrap" :style="`background: ${backgroundColor}`">
    <div class="slide-image-list">
      <div
        class="m-img"
        :class="{ active: true }"
        v-for="(item, index) in imageData"
        @click="showpic(item)"
        :key="index"
      >
        <el-image
          style="width: 50px; height: 50px; display: block"
          :src="item.image_link"
          :title="item.snippet"
          :alt="item.snippet"
          fit="cover"
        />
      </div>
    </div>
  </div>
</template>
<script>
/*
  纯CSS，实现简单，但图片顺序是每列从上往下排列
*/
export default {
  name: "Waterfall",
  props: {
    imageData: {
      // 瀑布流的图片数组
      type: Array,
      required: true,
      default: () => {
        return [];
      },
    },
    backgroundColor: {
      // 瀑布流区域背景填充色
      type: String,
      default: "#F2F4F8",
    },
  },
  computed: {},
  methods: {
    showpic(item) {
      this.$emit("showpic", item);
    },
    linktourl(src) {
      window.open(src, "_blank");
    },
  },
};
</script>
<style lang="scss" scoped>
.m-waterfall-wrap {
  display: flex;
  height: 50px;
  overflow: auto;
  position: relative;

  .slide-image-list {
    display: flex;
    position: absolute;
    top: 0;
    left: 0;
  }

  .m-img {
    border-radius: 10px;

    .el-image {
      cursor: pointer;
      margin-right: 5px;
    }
    .u-img {
      width: 100%;
      vertical-align: bottom;
    }
  }
}
</style>
